package com.aiflow.Action;



import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.List;



public class callTellThread extends Thread{
	
	//获取改地市中所有打电话人的中间变量
	private String tele;	
	private CallTel ht ;
	
	public callTellThread(String tele,CallTel callTel){
		this.tele = tele;
		this.ht = callTel;
	}

	public void run(){ 
		HttpURLConnection httpurl = null;
		try{
			String sendmes = "http://"+ht.ip+":"+ht.port+"/webservice/ctioriginatetts.php?webkey="+ht.webkey+"&channel=Local/"+tele+"@from-internal&context="+ht.context+"&exten="+ht.exten+"&priority="+ht.priority+"&callerid="+ht.callerid+"&variable="+ht.variable+ht.MVB_CALLER+"|MVB_CALLEE="+tele+"|MVB_DIRECT=OUT"+"&async="+ht.async+"&json="+ht.json+"&ttstext="+ht.sendContext;
			URL url = new URL(sendmes.trim());
			//记录发送时间
			String senddate = ht.sdf2.format(new Date());
//		log.info(sendmes);
		    httpurl = (HttpURLConnection) url.openConnection();
			 int loop = httpurl.getResponseCode();//判断请求是否成功(200表示成功!!!)
//		log.info("------------"+loop);
//			if(loop != 200){
//				ht.log.info("发送短信地址连接失败!!!");
//				return;
//			}
			//设置连接主机超时（单位：毫秒） 
			httpurl.setConnectTimeout(30000);
			//设置从主机读取数据超时（单位：毫秒）
			httpurl.setReadTimeout(120000); 
		} catch (Exception e) {
			e.printStackTrace();
			ht.log.info(e.getMessage());
		}finally{
			if(ht.httpurl != null){
				httpurl.disconnect();
			}
		}
	}
}
